home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip: Special XP & Vista
/
Chip Spesial XP & Vista.iso
/
3_Gadgets
/
UEFA_Informer_Gadget
/
UEFAinfo.gadget
/
scripts
/
settings.js
< prev
Wrap
Text (UTF-16)
|
2008-03-24
|
7KB
|
111 lines
function init_Settings()
{
System.Gadget.onSettingsClosing = settings_Closing;
var version = document.getElementById("version");
version.innerHTML = "version: " + System.Gadget.version;
get_Country();
}
function get_Country()
{
var country = document.getElementById("countryList");
country.innerHTML = "<p class='centered'><img src='images/loaderFly.gif'></p>";
var httpreq = getHTTPObject();
var url = "http://soccerdb.890m.com/xml/countrylist.xml";
httpreq.open("GET", url, true);
httpreq.onreadystatechange = function ()
{
if (httpreq.readyState == 4)
{
if (httpreq.status == 200)
{
var xml = httpreq.responseXML;
create_List(xml);
} else
{
country.innerHTML = "<p class='centered'>Error: Status " + httpreq.status + " (" + httpreq.statusText + ")</p>";
}
}
}
httpreq.send ();
}
function create_List(xml)
{
var countryNode = xml.documentElement.getElementsByTagName("country");
var country = document.getElementById("countryList");
country.innerHTML = "";//Clean list
for (var i = 0; i < countryNode.length; i++)
{
var countryId = getAttributeValue(countryNode[i], "id");
var countryName = getChildNodeValue(countryNode[i], "name");
var countryLogo = getChildNodeValue(countryNode[i], "logo");
var countryValue = countryId + ";" + countryName + ";" + countryLogo;
create_Input(i, countryValue, countryName, country);
}
// Check countries from main menu
var input = country.getElementsByTagName("input");
var checkedValue = System.Gadget.Settings.read("checkedValue").split(",");
for (var i = 0; i < input.length; i++)
{
for (var j = 0; j < checkedValue.length; j++)
{
if (checkedValue[j] == input[i].value) input[i].checked = true;
}
}
}
function create_Input(id, value, text, parentNode)
{
var input = document.createElement("input");
input.type = "checkbox";
input.value = value;
input.id = "inp" + id;
parentNode.appendChild(input);
var label = document.createElement("label");
label.htmlFor = "inp" + id;
parentNode.appendChild(label);
var textNode = document.createTextNode(text);
label.appendChild(textNode);
label.insertAdjacentHTML("afterEnd", "<br>");
}
function check_All()
{
var country = document.getElementById("countryList");
var input = country.getElementsByTagName("input");
var checkAll = document.getElementById("checkAll");
for (var i = 0; i < input.length; i++)
{
input[i].checked = checkAll.checked;
}
}
function settings_Closing(event)
{
if (event.closeAction == event.Action.commit) save_Settings();
event.cancel = false;
}
function save_Settings()
{
var country = document.getElementById("countryList");
var input = country.getElementsByTagName("input");
var j = 0;
var checkedValue = [];
for (var i = 0; i < input.length; i++)
{
if (input[i].checked)
{
checkedValue[j] = input[i].value;
j++;
}
}
System.Gadget.Settings.write("checkedValue", checkedValue);
System.Gadget.Settings.write("countrySelId", "");
System.Gadget.Settings.write("numSelOption", "");
System.Gadget.document.parentWindow.init_Menu();
}